<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:SamSoft.Controls"
    xmlns:coding4fun="clr-namespace:Coding4Fun.Phone.Controls"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    xmlns:samSoft="clr-namespace:SamSoft.Controls"
    >

    <Style TargetType="samSoft:ListBoxCheckBoxItem">

        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="IsChecked" Value="False"></Setter>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBoxItem">
                    <Border x:Name="LayoutRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver"/>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="LayoutRoot">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TransparentBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ContentContainer"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Unselected"/>
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneAccentBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CheckStates">

                                <VisualStateGroup.Transitions>
                                    <VisualTransition From="ShowCheck" To="HideCheck" GeneratedDuration="0:0:0.3"></VisualTransition>
                                    <VisualTransition From="HideCheck" To="ShowCheck" GeneratedDuration="0:0:0.3"></VisualTransition>
                                </VisualStateGroup.Transitions>

                                <VisualState x:Name="HideCheck">

                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="X" Storyboard.TargetName="TranslateCheckBox">
                                            <DiscreteDoubleKeyFrame KeyTime="0" Value="0"></DiscreteDoubleKeyFrame>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>

                                    <!--<Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Width" Storyboard.TargetName="ContentCheckBox">
                                            <DiscreteDoubleKeyFrame KeyTime="0" Value="0"></DiscreteDoubleKeyFrame>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>-->
                                </VisualState>
                                <VisualState x:Name="ShowCheck">

                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="X" Storyboard.TargetName="TranslateCheckBox">
                                            <DiscreteDoubleKeyFrame KeyTime="0" Value="80"></DiscreteDoubleKeyFrame>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>

                                    <!--<Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Width" Storyboard.TargetName="ContentCheckBox">
                                            <DiscreteDoubleKeyFrame KeyTime="0" Value="80"></DiscreteDoubleKeyFrame>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>-->
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Grid Margin="-80,0,0,0">

                            <Grid.RenderTransform>
                                <TranslateTransform x:Name="TranslateCheckBox" X="0"></TranslateTransform>
                            </Grid.RenderTransform>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>

                            <!--<ContentControl x:Name="ContentCheckBox">                                
                                <CheckBox x:Name="CheckBox" Style="{TemplateBinding samSoft:ListBoxCheckBoxItem.CheckBoxStyle}"></CheckBox>
                            </ContentControl>-->

                            <CheckBox x:Name="CheckBox" Width="80" Style="{TemplateBinding samSoft:ListBoxCheckBoxItem.CheckBoxStyle}"></CheckBox>
                            <ContentControl Grid.Column="1" x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>

                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
